package com.exsun.ex1077.ui.activity.msg

import android.os.Bundle
import android.view.View
import com.exsun.ex1077.R
import com.exsun.ex1077.databinding.ActivityMsgDetailBinding
import com.exsun.ex1077.network.entity.Msg
import com.zhangping.fastjetpack.base.BaseActivity
import com.zhangping.fastjetpack.extend.showConfirm

/**
 * 描述：消息详情
 * 作者：ZhangPing
 * 创建时间：2022/8/9 16:14
 */
class MsgDetailActivity: BaseActivity<MsgDetailViewModel, ActivityMsgDetailBinding>() {

    override fun title() = "消息详情"
    override fun actionIcon() = R.drawable.garbage

    private var position: Int = 0

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.vm = mViewModel
        super.initView(savedInstanceState)
        val model = intent.getSerializableExtra("model") as Msg
        position = intent.getIntExtra("position", 0)
        mViewModel.model.set(model)
    }

    override fun onActionClick(view: View) {
        showConfirm("确定要删除当前消息吗？"){
            mViewModel.removeMsg(mViewModel.model.get()?.id ?: "").observe(this){
                setResult(RESULT_OK)
                finish()
            }
        }
    }

}